function getValue(condition) {
  console.log(typeof value);
  if (condition) {
    var value = 'blue';
    // other code
    return value;
  }

  // value exists here with a value of undefined
  if (typeof value == 'undefined') {
    try {
      if (value == null) return value;
    } catch (err) {
      return null;
    }
  }
  return value;
}

function TDZ(condition) {
  if (condition) {
    console.log(typeof value); //Any attempt to access a variable in the TDZ results in a runtime error.
    let value = 'blue';
  }
  // other code
  return true;
}

function BindingBlock_loop() {
  for (var i = 0; i < 10; i++) {}

  return i;
}

function BindingBlock_FunctionsInLoops() {
  var funcs = [];
  for (var i = 0; i < 10; i++) {
    funcs.push(function () {
      console.log(i);
    });
  }
  return funcs;
}

module.exports = {
  getValue,
  TDZ,
  BindingBlock_loop,
  BindingBlock_FunctionsInLoops,
};
